home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0019_Trap CTRL-BREAK.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  77 lines

  1. {  >> What sort of code do I need to include in a pascal Program (Writen in
  2.   >> Borland Pascal 6.0) to disable CTRL-BREAK and CTRL-C?
  3. }
  4. Unit CAD;
  5.  
  6. Interface
  7.  
  8. Uses Dos;
  9.  
  10. Var
  11.   Int9Handler  : Pointer;
  12.  
  13. Procedure InterceptCtrlAltDel;
  14. Procedure RestoreCAD;
  15.  
  16.   Implementation
  17.  
  18. Procedure InterceptCtrlAltDel; Assembler;
  19.  
  20. Const
  21.   Ctrl         = 4;
  22.   Alt          = 8;
  23.   Del          = $53;
  24.   KbdPort      = $60;                  { Keyboard port }
  25.   KbdCtrlPort  = $61;                  { Keyboard control port }
  26.   PIC          = $20;                  { 8259 Interrupt controller }
  27.   EOI          = $20;                  { end-of-interrupt }
  28.  
  29.   Asm
  30.  
  31.   PUSH   AX
  32.   PUSH   DS
  33.   MOV    AX, SEG @Data
  34.   MOV    DS, AX
  35.   STI
  36.   in     AL, KbdPort
  37.   and    AL, 01111111b
  38.   CMP    AL, Del
  39.   JNE    @2
  40.  
  41.   @1 :     MOV    AH, 2               { BIOS Get keyboard flags service }
  42.   inT    16h
  43.   TEST   AL, Ctrl + Alt
  44.   JNZ    @3
  45.  
  46.   @2 :     PUSHF
  47.   CALL   [Int9Handler]
  48.   JMP    @4
  49.  
  50.   @3 :     in     AL, KbdCtrlPort
  51.   MOV    AH, AL
  52.   or     AL, 10000000b
  53.   OUT    KbdCtrlPort, AL
  54.   XCHG   AH, AL
  55.   OUT    KbdCtrlPort, AL
  56.   CLI
  57.  
  58.   MOV    AL, EOI
  59.   OUT    PIC, AL
  60.   @4 :     POP    DS
  61.   POP    AX
  62.   IRET                       { make sure we return correctly }
  63. end;  { InterceptCtrlAltDel }
  64.  
  65. Procedure RestoreCAD;
  66.  
  67. begin
  68.   SETinTVEC (9, Int9Handler);
  69. end;  { RestoreCAD }
  70.  
  71.  
  72. begin
  73.   GETinTVEC (9, Int9Handler);
  74.   SETinTVEC (9, @InterceptCtrlAltDel);
  75. end. {Unit CAD}
  76.  
  77.